package app.repositories.impl;

import java.util.List;

import javax.persistence.EntityManager;

import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;

import app.models.Log;
import app.repositories.LogRepository;
import app.repositories.Repository;
import app.util.Constants;
import br.com.caelum.vraptor.ioc.Component;

@Component
public class LogRepositoryImpl extends Repository<Log, Long> implements LogRepository{

	protected LogRepositoryImpl(EntityManager entityManager) {
		super(entityManager);
	}
	
	public List<Log> findLogsByPeriodAndUser (String dataInicial, String dataFinal, String usuario) {
		Criteria criteria = createCriteria();
		
		criteria.add(Restrictions.between(Constants.DATA_CADASTRO, dataInicial, dataFinal));
		
		return (List<Log>) criteria.list();
	}

}
